home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-11 | 3.5 KB | 78 lines | [TEXT/PJMM] |
- program StandardGetFolder;
-
- {/*******************************************************************************}
- {* StandardGetFolder Sample Program by Ken Kirksey *}
- {* *}
- {* This little program gives an example of how to use the standard get *}
- {* folder function. *}
- {* *}
- {* Requires: System 7.0 or later. ANSI & MacTraps libraries. *}
- {*******************************************************************************/}
- { Converted to Pascal by Peter N Lewis <peter@cujo.curtin.edu.au> Dec 1992 }
-
- uses
- StandardGetFolder;
-
- var
- mySFReply: StandardFileReply;
- where: Point;
- iErr: OSErr;
- myFSSpec: FSSpec;
- buffer: Str255;
- inOutCount: longInt;
- testFile: integer;
- oe: OSErr;
- begin
- SetPt(where, 60, 60);
-
- {/*-------------------------------------------------------------------------+}
- {| Call Standard get folder, passing the point you want it to be drawn at, |}
- {| the message you want to be displayed above the file list, and a pointer |}
- {| to a StandardFileReply record. |}
- {+-------------------------------------------------------------------------*/}
- StandardGetFolder(where, 'Home Free:', mySFReply);
-
- {/*-------------------------------------------------------------------------+}
- {| Ok, the volume reference number and directory ID of the folder the user |}
- {| chose are returned in the sfFile field of the Standard File Reply. Use |}
- {| use this information to build an FSSpec record that references the file |}
- {| you wish to create. |}
- {+-------------------------------------------------------------------------*/}
- iErr := FSMakeFSSpec(mySFReply.sfFile.vRefNum, mySFReply.sfFile.parID, 'MyFile.test', myFSSpec);
- if iErr <> noErr then
- writeln(iErr);
-
- {/*-------------------------------------------------------------------------+}
- {| Now using the FSSpec record you made, create the file. I've got it set |}
- {| to create an Alpha (my favorite text editor) file. Change the creator |}
- {| code to suit your taste. |}
- {+-------------------------------------------------------------------------*/}
- iErr := FSpCreate(myFSSpec, 'ALFA', 'TEXT', mySFReply.sfScript);
- if iErr <> noErr then
- writeln(iErr);
-
- {/*-------------------------------------------------------------------------+}
- {| Open the file and write a short message to it. |}
- {+-------------------------------------------------------------------------*/}
- iErr := FSpOpenDF(myFSSpec, fsRdWrPerm, testFile);
- if iErr <> noErr then
- writeln(iErr);
-
- iErr := SetEOF(testFile, 0);
- if iErr <> noErr then
- writeln(iErr);
-
- buffer := concat('Holey Smokes, It Worked!!!', chr(13));
-
- inOutCount := length(buffer);
- iErr := FSWrite(testFile, inOutCount, @buffer[1]);
- if iErr <> noErr then
- writeln(iErr);
-
- {/*-------------------------------------------------------------------------+}
- {| Close the file. |}
- {+-------------------------------------------------------------------------*/}
- iErr := FSClose(testFile);
- if iErr <> noErr then
- writeln(iErr);
- end.